<?php 
defined('IN_PHPCMS') or exit('No permission resources.');
pc_base::load_sys_class('base');
class index extends base{
	public $db,$setting;
	function __construct() {
		parent::__construct();
		$this->db = pc_base::load_model('talent_model');
	}
	
	/**
	 * 人才导师列表
	 */
	public function lists() 
	{
		$temp = "list";
		//添加title
		$SEO['title'] = "师资力量-新丝路集团";
		$page = $_GET['page']?intval($_GET['page']):1;
		$max = 10;
		$offset = ($page-1)*$max;
		$list = file_get_contents(API_URL."/xinsilu/v1/talent/listByCondition?max=".$max."&offset=".$offset."&isMentor=1");
		$list = json_decode($list,true);
		$front_pages = front_pages($list['data']['totalCount'], $page, $max);
		$list = $list['data']['talents'];
		//var_dump($list);die;
		include template('talent', $temp);
	}

	/**
	 * 人才详情
	 */
	public function show()
	{
		$temp = "show";
		//添加title
		$SEO['title'] = "师资力量-新丝路集团";
		$id = $_GET['id']?intval($_GET['id']):'';
		if (!$id) {
			showmessage(L('information_does_not_exist'),'blank');
		}

		// $pre = $this->db->get_one($where.' is_mentor = 1 and id<'.$id, 'id', 'id desc');
		// $next = $this->db->get_one($where.' is_mentor = 1 and id>'.$id, 'id', 'id asc');
		// //上一篇
		// if ($pre['id']) {
		// 	$preInfo = file_get_contents(API_URL."/xinsilu/v1/talent/".$pre['id']);
		// 	$preInfo = json_decode($preInfo,true);
		// 	$previous_page = $preInfo['data'];
		// 	$previous_page['title'] = $previous_page['realName'];
		// }
		// //下一篇
		// if ($next['id']) {
		// 	$nextInfo = file_get_contents(API_URL."/xinsilu/v1/talent/".$next['id']);
		// 	$nextInfo = json_decode($nextInfo,true);
		// 	$next_page = $nextInfo['data'];
		// 	$next_page['title'] = $next_page['realName'];
		// }

		// if(empty($previous_page)) {
		// 	$previous_page = array('title'=>'第一页', 'thumb'=>IMG_PATH.'nopic_small.gif', 'url'=>'javascript:alert(\''.'第一页'.'\');');
		// } else {
		// 	$previous_page['url'] = "/index.php?m=talent&c=index&a=show&id=".$previous_page['id'];
		// } 

		// if(empty($next_page)) {
		// 	$next_page = array('title'=>'最后一页', 'thumb'=>IMG_PATH.'nopic_small.gif', 'url'=>'javascript:alert(\''.'最后一页'.'\');');
		// } else {
		// 	$next_page['url'] = "/index.php?m=talent&c=index&a=show&id=".$next_page['id'];
		// }
		
		//取人才信息
		$talent = file_get_contents(API_URL."/xinsilu/v1/talent/".$id);
		$talent = json_decode($talent,true);
		$info = $talent['data'];
		//取关联图集
		$t_pic = file_get_contents(API_URL."/xinsilu/v1/talent/talentResourceList?max=10&talentId=".$id."&type=3&siteid=1");
		$t_pic = json_decode($t_pic,true);
		$talentPics = $t_pic['data'];
		if (!empty($talentPics)) {
			foreach ($talentPics as $key => $v) {
				$pics = file_get_contents(API_URL."/xinsilu/v1/pictureNsr/getPictureNsrById?id=".$v['id']);
				$pics = json_decode($pics,true);
				$talentPics[$key]['pictureurls'] = json_decode($pics['data']['pictureurls'],true);
			}
		}
		$pics_id = $talentPics[0]['id'];
		include template('talent', $temp);
	}

	public function ajax_pics ()
	{
		$id = $_POST['id']?intval($_POST['id']):'';
		$pics = file_get_contents(API_URL."/xinsilu/v1/pictureNsr/getPictureNsrById?id=".$id);
		$pics = json_decode($pics,true);
		echo $pics['data']['pictureurls'];die;
	}

}
?>